unit uSBDUnit_TestScheduler;
interface
uses Generics.Collections, Messages, uSBDUnit_Types, uSBD_BaseTypes;

const
  DefaultMessageNum = WM_USER + 21;
type

TNodeStatus = (
  nsNeutral,    // This node is in the queue to be processed.
  nsDoing,      // We are currently procesing this node or one of its children.
  nsDone,       // This node has been processed, either successfully or not.
  nsSkipped     // This node will not be processed.
  );
TNodeStatusSet = set of TNodeStatus;


ITestPoint = interface
['{92541484-4115-437E-B2AC-978617026259}']
    {$REGION 'property accessors'}
    function  GetStatus: TNodeStatus;
    procedure SetStatus( Value: TNodeStatus);
    function  GetExecResult: TExecutionResult;
    procedure SetExecResult( Value: TExecutionResult);
    {$ENDREGION}
    procedure PreExecute;
    function  Execute: boolean;
    procedure PostExecute( isTimedOut: boolean);
    function  TimeOut: integer;
    function  doInbackground: boolean;

    property Status: TNodeStatus   read GetStatus write SetStatus;
    property ExecutionResult: TExecutionResult  read GetExecResult write SetExecResult;
  end;

TTestEnumerable = TEnumerable<ITestPoint>;

ITestSchedulerClient = interface
  ['{D4D426D6-03FC-49D4-8C9F-5E565F7F5F12}']
  procedure NodeStatusChanged( Node: ITestPoint);
  procedure RunStatusPotentiallyChanged;
  function  DoContinue: boolean; // False if user abort.
  end;


// Implicit contructor inputs:
//  *  FWindowClient:  IMainThreadedWindowedClient;  -- Injected as a live service.
//  *  FClient: ITestSchedulerClient -- Injected as a live service. This is a vista to the Engine.
//  *  FMill: IJobMill;  -- Injected as a created service, But may be released and a new one created as required.
//  *  TestEnumerable1: TTestEnumerable; -- A getter service is injected.
//      The services is a created one. This service has in turn its root node
//      injected. The root node is a live service.
//  *  doBreakOnFirstFail: boolean;  // Set by the client as a parameter to the Run method. Not a property.

ITestEnumerableGetter = interface
  ['{88E79DD4-F9E0-4C9C-A5AA-46C527DB698D}']
    function CreateTestEnumerable: TTestEnumerable;
    // ^--- Uses an [Injection('EnumerationRoot')] to locate the root node.
  end;

ITestScheduler = interface
  ['{36F259B2-91EF-4F30-B58F-40D139B5E4B8}']
    procedure Run( doBreakOnFirstFail: boolean);
    procedure Clear;
    function  isDone: boolean;
  end;


TSBDUnit_SchedulerException = class( TSBDUnit_Exception) end;

implementation



end.
